export const crudOptions = (vm) => {
  return {
    pageOptions: {
      compact: true
    },
    options: {
      tableType: 'vxe-table',
      rowKey: true, // 必须设置，true or false
      rowId: 'id',
      height: '100%', // 表格高度100%, 使用toolbar必须设置
      highlightCurrentRow: false

    },
    rowHandle: false,
    indexRow: { // 或者直接传true,不显示title，不居中
      title: '序号',
      align: 'center',
      width: 70
    },

    viewOptions: {
      componentType: 'form'
    },
    formOptions: {
      defaultSpan: 12, // 默认的表单 span
      width: '900px'
    },
    columns: [
      {
        title: 'ID',
        key: 'id',
        show: false,
        width: 70,
        form: {
          disabled: true
        }
      }, {
        title: '租户名称',
        key: 'client',
        type: 'selector-table',
        dict: {
          cache: true, // 表单的dict可以禁用缓存
          url: '/api/tenant/client/',
          value: 'id', // 数据字典中value字段的属性名
          label: 'name' // 数据字典中label字段的属性名
        },
        minWidth: 160,
        search: {
          disabled: false
        },
        form: {
          rules: [ // 表单校验规则
            { required: true, message: '租户必填项' }
          ],
          component: {
            span: 12,
            placeholder: '请选择租户',
            elProps: {
              tableConfig: {
                pagination: true,
                multiple: false,
                columns: [
                  {
                    prop: 'name',
                    label: '租户名称'
                  }, {
                    prop: 'schema_name',
                    label: '租户标识'
                  }
                ]
              }
            }
          },
          itemProps: {
            class: { yxtInput: true }
          }
        }
      }, {
        title: '开户套餐',
        key: 'package_manage',
        type: 'selector-table',
        dict: {
          cache: true, // 表单的dict可以禁用缓存
          url: '/api/tenant/package_manage/?status=True',
          value: 'id', // 数据字典中value字段的属性名
          label: 'name' // 数据字典中label字段的属性名
        },
        minWidth: 160,
        search: {
          disabled: false
        },
        form: {
          rules: [ // 表单校验规则
            { required: true, message: '开户套餐必填项' }
          ],
          component: {
            span: 12,
            placeholder: '请选择开户套餐',
            elProps: {
              tableConfig: {
                pagination: true,
                multiple: false,
                columns: [
                  {
                    prop: 'name',
                    label: '套餐名称'
                  }, {
                    prop: 'description',
                    label: '套餐说明'
                  }
                ]
              }
            }
          },
          itemProps: {
            class: { yxtInput: true }
          }
        }
      }, {
        title: '有效天数',
        key: 'trial_cut_off_time',
        type: 'input',
        width: 120,
        search: {
          disabled: true
        }
      },
      {
        title: '支付金额',
        key: 'money',
        width: 160,
        type: 'number'
      },
      {
        title: '支付类型',
        key: 'payment_status',
        type: 'select',
        width: 120,
        dict: {
          data: [{ label: '免费体验', value: 0 }, { label: '微信支付', value: 1 }, { label: '支付宝支付', value: 2 }, { label: '线下支付', value: 3 }]
        },
        search: {
          disabled: false,
          component: {
            disabled: false
          }
        }
      },
      {
        title: '支付状态',
        key: 'status',
        type: 'select',
        width: 120,
        dict: {
          data: [{ label: '取消支付', value: 0, color: 'danger' }, { label: '待支付', value: 1, color: 'primary' }, { label: '支付完成', value: 2, color: 'success' }]
        },
        search: {
          disabled: false,
          component: {
            disabled: false
          }
        }
      }
    ].concat(vm.commonEndColumns({
      description: { showTable: false, showForm: false }
    }))
  }
}
